<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>人员维护新增</title>
<%@include file="../../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css"/>
<script type="text/javascript" src="${jspath }/jquery-1.4.4.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />
<script type="text/javascript" src="${jspath}/load_layer.js"></script>
<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
	<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>
<style type="text/css">
.formError .formErrorContent {
    -moz-border-radius: 6px 6px 6px 6px;
    -moz-box-shadow: 0 0 6px #000000;
    background: none repeat scroll 0 0 #EE0101;
    border: 2px solid #DDDDDD;
    color: #FFFFFF;
    font-family: tahoma;
    font-size: 11px;
    padding: 4px 10px;
    width: 100px;
}
</style>
<script type="text/javascript">


$(function(){
	
	addValidationRule();
	
	$("#create_employee").validationEngine(
			{
             promptPosition:"topLeft",
             success:false,
             validationEventTriggers : "change blur",
			 failure:function(){} 
	});
	
	$("#add_zz1").click(function() {
		if($(":radio").length > 0){
			
			jAlert("已经存在组织信息,需要先删除当前的组织信息再新增！","提示信息");
		    return false;
		}
		
		loadLayer(this,"${webcontext}/common/toUserGroupAndOrgPage?ownerId=${ownerId}",753,200);
	});
	
	/*点击删除*/
	$("#delete").click(function(){
		
		if($(":radio").length == 0){
			jAlert("请增加岗位和组织！","提示信息");
	    	return;
	    }
		if($(":radio:checked").length == 0){
			jAlert("请选择组织！","提示信息");
	    	return;
	    } 
		
		jConfirm("确认删除此记录？","确认提示",function(result){
    		if(result == true)
    		{	
    			 $("#usrgrp_org_table tr:has(:checked)").remove();
   			     $("#usrgrp_org_table tr:odd").attr("class", "odd");
   			     $("#usrgrp_org_table tr:even").attr("class", "even");
    		}
    	});
	});
	
	$("#save").click(function(){
		
		if(!$("#create_employee").validationEngine(
				{
	             promptPosition:"topLeft",
	             validationEventTriggers : "change blur",
	           	 returnIsValid:true
				 })){
			return;
		}
		
		$.get("${webcontext}/dm/dealer/employeemgnt/validatecertificatecode?certificatecode=" + $("#certificateCode").val()+"&timestamp="+ Date.parse(new Date()), function(result){
    		
    		if (result == "true"){
    			jAlert("证件号码已经存在！", "提示信息");
    	        $("#certificateCode").val("");
    	        return ;
    		}
    			
    	});
		
		$("#operationType").val("1");
		if($(":radio").length == 0){
			jAlert("请增加岗位和组织！","提示信息");
	    	return;
	    }
		
		jConfirm("确认保存此记录？","确认提示",function(result){
    		if(result == true)
    		{	
            	$("#create_employee").submit();
    		}
    	});
		
	});
	
	$("#saveAndSubmit").click(function(){
		
		if(!$("#create_employee").validationEngine(
				{
	             promptPosition:"topLeft",
	             validationEventTriggers : "change blur",
	           	 returnIsValid:true
				 })){
			return;
		}
		$.get("${webcontext}/dm/dealer/employeemgnt/validatecertificatecode?certificatecode=" + $("#certificateCode").val()+"&timestamp="+ Date.parse(new Date()), function(result){
    		
    		if (result == "true"){
    			jAlert("证件号码已经存在！", "提示信息");
    	        $("#certificateCode").val("");
    	        return;
    		}
    			
    	});
		$("#operationType").val("2");
		if($(":radio").length == 0){
			jAlert("请增加岗位和组织！","提示信息");
	    	return;
	    }
		
		jConfirm("确认保存并提交此记录？","确认提示",function(result){
    		if(result == true)
    		{	
            	$("#create_employee").submit();
    		}
    	});
		
	});
	
	$("#isBrandTraining").change(function(){
		
		var $passTrainingDateStr = $("#passTrainingDateStr");
		
		if(this.value == "1"){
			
			$passTrainingDateStr.parents("td").show();
			$passTrainingDateStr.parents("td").prev().show();
			$passTrainingDateStr.removeAttr("disabled");
			
		}else{
			$passTrainingDateStr.parents("td").hide();
			$passTrainingDateStr.parents("td").prev().hide();
			$passTrainingDateStr.val("");
			$passTrainingDateStr.attr("disabled", "disabled");
			
		}
		
	});
	
    $("#hasDriverLicense").change(function(){
		var $obj = $("#driverLicenseDateStr");
    	
		if(this.value == "1"){
			
			$obj.parents("td").show();
			$obj.parents("td").prev().show();
			$obj.removeAttr("disabled");
			
		}else{
			$obj.parents("td").hide();
			$obj.parents("td").prev().hide();
			$obj.val("");
			$obj.attr("disabled", "disabled");
		}
		
	});
    
    $("#certificateCode").blur(function(){
    	
    	$.get("${webcontext}/dm/dealer/employeemgnt/validatecertificatecode?certificatecode=" + $("#certificateCode").val()+"&timestamp="+ Date.parse(new Date()), function(result){
    		
    		if (result == "true"){
    			jAlert("证件号码已经存在！", "提示信息");
    	        $("#certificateCode").val("");
    	        return;
    		}
    			
    	});
    }); 
});

function idCardValid(value){
	var strP=/^(\d{15}|(\d{17}[\dXx]))$/;
	if(strP.test(value)){
		return true;
	}else{
		return false;
	}
}



function validateOnboardDate(){
	   
	var startDateValue = $('#onboardDateStr').val();
	var endDateValue = $('#currentDate').val();
	if((startDateValue != null && startDateValue != "") && (endDateValue != null && endDateValue != "")){
		if(endDateValue < startDateValue){
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}


function addValidationRule(){
   $.validationEngineLanguage.allRules["validateIdCard"] ={ 
   	        "nname":"validateIdCard", 
   	        "alertText":"无效的身份证号！"
   };
   
   $.validationEngineLanguage.allRules["validateOnboardDate"] ={ 
  	        "nname":"validateOnboardDate", 
  	        "alertText":"必须早于当前日期！"
  };
   
}

</script>

</head>
<body>

	<!-- content -->
	<div id="content">
		<!-- wrap -->
		<div id="wrap">
        <!-- breadcrumb -->
			<div id="breadcrumb">人员维护</div>

			<!-- /breadcrumb -->
			<!-- info_div -->
 <form:form id="create_employee" action="${webcontext}/dm/dealer/employeemgnt/saveEmployee" method="post" modelAttribute="submitDto" enctype="multipart/form-data">
 <form:hidden path="id"/>
 <input type="hidden" id="operationType" name="operationType"/>
		  <div class="input_div">
				<div class="title">
					<p>基本资料</p>
				</div>
                <div>
                
				 <style>
                .input_tab { table-layout:fixed; }
                </style>
				<table class="input_tab">
                    
                   <tr>
  <td colspan="6" class="spliterInput_Line">
    <img src="${webcontext}/images/pictures_l/spliterInput_line_03.gif" width="550" height="9" />
  </td>
</tr>
                    <tr>
                      <td class="label" align="right"><span class="need">*</span>员工姓名：</td>
                      <td align="left"><form:input path="employeeName" cssClass="validate[required,length[0,90]] text string"/></td>
                       <td class="label"><span class="need">*</span>性别：</td>
                       <td> <form:select path="genderId" cssClass="validate[required] sel">  
					  	 <form:option value="">请选择</form:option>
					  	   <core:forEach items="${gender}" var="codeInfo">
				         <form:option value="${codeInfo.id }">${codeInfo.value }</form:option>
				        </core:forEach>	
						</form:select></td>
                      <td class="label" align="right"></td>
                      <td align="left"></td>
                  </tr>
                     <tr>
                       <td class="label"><p><span class="need">*</span>手机：</p></td>
                      <td><form:input path="mobilePhone" cssClass="validate[custom[mobilePhone]] text"/></td>
                     <td class="label"><span class="need">*</span>电子邮件：</td>
                       <td colspan="3"><form:input path="email" cssClass="validate[custom[email],charLength[0,100]] text" cssStyle="width:386px;"/></td>
                       
                     </tr>
                     <tr>
                       <td class="label"><span class="need">*</span>证件类型：</td>
                       <td><form:select path="certificateId" class="validate[required] sel">  
					  	   <form:option value="">请选择</form:option>
					  	   <core:forEach items="${certificateType}" var="codeInfo">
				         <form:option value="${codeInfo.id }">${codeInfo.value }</form:option>
				        </core:forEach>	
						</form:select></td>
                       <td class="label"><span class="need">*</span>证件号码：</td>
                       <td><form:input path="certificateCode" cssClass="validate[required,length[0,40],funcCall[validateIdCard] text"/></td>
                       <td class="label"><span class="need">*</span>婚姻状况：</td>
                       <td><form:select path="marriageId" class="validate[required] sel">  
					  	 <form:option value="">请选择</form:option>
					  	   <core:forEach items="${marriage}" var="codeInfo">
				         <form:option value="${codeInfo.id }">${codeInfo.value }</form:option>
				        </core:forEach>	
						</form:select></td> 
                    </tr>
                    
                    <tr> 
                        <td class="label"><span class="need">*</span>籍贯：</td>
						<td>
							<form:input path="birthPlace" cssClass="validate[required,length[0,30]] text"/>
						</td>
                        <td class="label"><span class="need">*</span>生日：</td>
						<td>
							<form:input path="birthDateStr" cssClass="validate[custom[date]] text date"/>
						</td>
                        <td class="label"><span class="need">*</span>学历：</td>
						<td>
						 <form:select path="educationId" class="validate[required] sel">  
					  	   	 <form:option value="">请选择</form:option>
					  	   <core:forEach items="${education}" var="codeInfo">
				         <form:option value="${codeInfo.id }">${codeInfo.value }</form:option>
				        </core:forEach>	
						</form:select>
						</td>
					</tr>
                    <tr>
                      <td class="label"><span class="need">*</span>住址：</td>
                      <td colspan="3"><form:input path="address" cssClass="validate[required,length[0,255]] text" cssStyle="width:386px;"/></td>
                      <td class="label"><p><span class="need">*</span>可导出数据：</p></td>
                       <td>
	                       <form:select path="exportData" class="validate[required] sel" disabled="true" >
						  	 <form:options items="${exportDataMap}"/>
							</form:select>
						</td>
                    </tr>
                   <tr>
  <td colspan="6" class="spliterInput_Line">
    <img src="${webcontext}/images/pictures_l/spliterInput_line_03.gif" width="550" height="9" />
  </td>
</tr>
                    <tr>
                      <td class="label"><p><span class="need">*</span>目前岗位入职</p>
                        <p>日期：</p>
                        <input type="hidden" id = "currentDate" value="${currentDate}">
                        </td>
                      <td><form:input path="onboardDateStr" cssClass="validate[required,custom[date],funcCall[validateOnboardDate]] text date"/></td>
                      <td class="label"><p><span class="need">*</span>首服务品牌</p>
                        <p>日期：</p></td>
                      <td><form:input path="brandFirstServiceDateStr" cssClass="validate[required,custom[date]] text date"/></td>
                      <td class="label">&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="label"><p><span class="need">*</span>是否受过品牌培训：</p></td>
                      <td>	 <form:select path="isBrandTraining" class="validate[required] sel">  
					  	 <form:option value="">请选择</form:option>
					  	 <%= CodeTextUtils.getOptions("EmployeeInfo.yesOrNo","" ) %>
						</form:select></td>
                      <td class="label yes1" style="display:none;"><p><span class="need">*</span>通过岗位培训日期：</p></td>
                      <td class="yes1" style="display:none;"><form:input path="passTrainingDateStr" cssClass="validate[required,custom[date]] text date" disabled="true"/></td>
                      <td class="label">&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="label"><p><span class="need">*</span>是否有驾照：</p></td>
                      <td> <form:select path="hasDriverLicense" class="validate[required] sel">  
					  	 <form:option value="">请选择</form:option>
					  	  <%= CodeTextUtils.getOptions("EmployeeInfo.yesOrNo","" ) %>
						</form:select></td>
                      <td class="label yes2" style="display:none;"><p><span class="need">*</span>领照日期：</p></td>
                      <td class="yes2" style="display:none;"><form:input path="driverLicenseDateStr" cssClass="validate[required,custom[date]] text date" disabled="true"/></td>
                      <td class="label">&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
				</table>
		    </div>
		  </div>
			<!-- /info_div -->
            
            <div class="spliter h_10"></div>           
             <div class="spliter h_5"></div>
            
            <!-- info_div -->
			<div class="info_div">
            	<div class="title"><p class="min" title="点击展开/隐藏详细信息">组织</p></div>
                <div>
                    <div class="page_div">
                        <div class="page_info">
                        <a class="add" id="add_zz1">新增</a>
                        <a  id="delete" class="delete">删除</a>
                        <input type="hidden" id="maxindex"  name="maxindex" value="0"/>
                        </div>
                    </div>
                    <div class="data_div">
                         <table id ="usrgrp_org_table" class="data_tab">
                            <tr>
                              <th class="w_5 center">选择</th>
                              <th class="w_20">岗位</th>
                              <th class="w_20">默认岗位</th>
                                <th class="w_20">组织名称</th>
                                <th class="w_20">组织主管</th>
                                <th class="w_20">上级组织名称</th>
                            </tr>
                         </table>

                    </div>
                </div>
			</div>
			<!-- /info_div -->
            
            <div class="btn_div">
<!--                <input type="button" class="btn" id="save" value="保存"/>-->
                <input type="button" class="btn" id="saveAndSubmit" value="保存并提交"/>
                <input type="button" class="btn" value="取消" onclick="javascript:window.history.back();"/>
            </div>
             
      </form:form>  
      </div>
		<!-- /wrap -->
	</div>
	<!-- /content -->

  </body>

</html>